package net.xinqushi.pthread.pthread;

/**
 * 如果保证线程是完全同时启动的，优先级大概率可以实现优先顺序
 * 但是一般无法控制线程的启动顺序，所以优先级顺序很难保证
 */
public class ThreadPriorityTest {

    public static void main(String[] args) {
        Thread lowPriorityThread = new Thread(()->{
            System.out.println(Thread.currentThread() + " is lower ");
        });
        lowPriorityThread.setPriority(Thread.MIN_PRIORITY);
        Thread thread = new Thread(()->{
            System.out.println(Thread.currentThread()  + " is higher ");
        });
        thread.setPriority(Thread.MAX_PRIORITY);
        lowPriorityThread.start();
        thread.start();
    }
}
